#ifndef __SystemSockets_h__
#define __SystemSockets_h__

#include "../base/types.h"
#include "SocketEventMonitor.h"

/// SystemSocket:
///     Tihs is a general representation for socket class on deferent system.

namespace Greatewall
{
    namespace Interface
    {
        class SystemSocket
        {
        public:
            SystemSocket(SocketEventMonitor& monitor, SysSockHandler hdl)
                : _hdl(hdl)
                , _inited(false)
                , _sock_event_monitor(monitor)
            {}

            virtual
            ~SystemSocket()
            {
                _sock_event_monitor.unregisterSocket(this);
            }

            SysSockHandler
            hdl() { return _hdl; }

            virtual void
            handleInbound() = 0;

            virtual bool
            handleOutbound() = 0;

            virtual void
            close() = 0;

        protected:
            SysSockHandler      _hdl;
            bool                _inited;
            SocketEventMonitor& _sock_event_monitor;
        };
    }
}

#endif
